import express from 'express';
import session from 'express-session';
import apiMidddleware from './apiMiddleware';
import bodyParser from 'body-parser';

const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.use(session({
    name: 'test',
    secret: 'sjhkv343jkkj@jjk',
    cookie: ({ maxAge: 120 * 60000 }),
    resave: true,
    saveUninitialized: false
}));

app.use(apiMidddleware);

app.disable('x-powered-by');

const server = app.listen(8080, () => {
    const { port } = server.address();
    console.info(`Listened at http://localhost:${port}`);
});